package com.ctshk.rpc.order.tour.mapper;

import com.ctshk.rpc.order.tour.dto.custom.CustomOrderTouristOtherFeeDTO;
import com.ctshk.rpc.order.tour.vo.TouristCollectionFeeJson;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.ctshk.common.service.mapper.CtsBaseMapper;
import com.ctshk.rpc.order.tour.entity.SeriesOrderTouristOtherFee;

import java.util.List;

/**
 * <p>
 * 系列团游客其他费用 Mapper 接口
 * </p>
 *
 * @author 谭响
 * @since 2021-01-22
 */
public interface SeriesOrderTouristOtherFeeMapper extends CtsBaseMapper<SeriesOrderTouristOtherFee> {

	/**
	 * 查询某旅客是否有退款的其它费用
	 * @param touristId
	 * @return
	 */
	@Select("select t.* from t_series_order_tourist_other_fee t left join t_series_order_tourist_refund tsotr on tsotr.id = t.relation_id where t.is_deleted = 0 and tsotr.is_deleted = 0 and t.tourist_id = 1 limit 1")
	SeriesOrderTouristOtherFee findRefundByTourist(Long touristId);

	/**
	 * 其他费用列表
	 * @param touristId
	 * @return
	 */
	@Select("SELECT *\n" +
			"FROM t_series_order_tourist_other_fee\n" +
			"WHERE tourist_id = #{tourist_id} AND is_deleted = 0")
	List<CustomOrderTouristOtherFeeDTO> queryByTourist(@Param("tourist_id") Long touristId);

	/**
	 * 查询旅客其他费用列表
	 * @param touristId
	 * @return
	 */
	@Select("SELECT fee_name AS projectName,amount AS totalAmount,fee_type AS adjustType\n" +
			"FROM t_series_order_tourist_other_fee\n" +
			"WHERE tourist_id = #{tourist_id} AND is_deleted = 0")
	List<TouristCollectionFeeJson> selectByTourist(@Param("tourist_id") Long touristId);
}
